﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data.EntityClient;

namespace DLL
{
    public static class DbContextFactory
    {
        public static RetailManagementEntities CreateDBContext(string connectionString)
        {
            RetailManagementEntities dbContext = new RetailManagementEntities(connectionString);
            return dbContext;
        }

        public static string CreateConnectionString(string connectionString)
        {
            SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(connectionString);
            EntityConnectionStringBuilder ecb = new EntityConnectionStringBuilder();
            ecb.Metadata = "res://*/RetailManagement.csdl|res://*/RetailManagement.ssdl|res://*/RetailManagement.msl";
            ecb.Provider = "System.Data.SqlClient";
            ecb.ProviderConnectionString = scsb.ConnectionString;
            return ecb.ConnectionString;
        }
    }
}
